-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[discussion] optimizing transform_geom
for repeated transformations
#799
Comments
@snowman2 maybe... is OCTNewCoordinateTransformation slow? |
Not that it is slow, but am wondering if GDAL 3 using PROJ 6 might impact performance. Not an issue with earlier versions of PROJ. Will have to time it on different versions and see if it matters. |
Actually, one thought I had was to allow users to pass in a list of geometries as well as a single geometry. This might make more sense. Thoughts? |
Okay, I modified the code to allow passing in a list of geometries and ran this test: from functools import partial
import geopandas
import fiona
from fiona.transform import transform_geom
from shapely.geometry import mapping
gdf = geopandas.read_file("zip://ne_110m_land.zip")
def base_transformer(geom, src_crs, dst_crs):
return transform_geom(
src_crs=src_crs,
dst_crs=dst_crs,
geom=geom,
antimeridian_cutting=True,
)
forward_transformer = partial(base_transformer, src_crs=gdf.crs, dst_crs="epsg:32628")
raw_geoms = gdf.geometry.apply(mapping)
def transform_geoms(raw_geoms):
transform_geom(
src_crs=gdf.crs,
dst_crs="epsg:32628",
geom=raw_geoms,
antimeridian_cutting=True,
) Is this a change you would like to see? |
@snowman2 I think a function to transform a sequence of geometries would be great. Should it return an iterator? |
Sounds good. I have a potential implementation in #811. |
Fiona/fiona/_transform.pyx
Line 133 in d6ec15f
Currently, the transformer is recreated each time the geometry transform occurs. I am wondering if creating a
Transformer
class similar to the one inpyproj
would make sense to prevent repeated re-creation of the transformer.https://pyproj4.github.io/pyproj/stable/advanced_examples.html#repeated-transformations
Thoughts?
The text was updated successfully, but these errors were encountered: