-
Notifications
You must be signed in to change notification settings - Fork 67
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
Feature by Feature Geometries #73
base: master
Are you sure you want to change the base?
Changes from all commits
6c2e17a
7cb7279
de2d87e
ce7f6fd
5f6d92e
c2f607c
1c9ff59
87b6328
10bacd4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,18 +1,33 @@ | ||||||
from itertools import tee | ||||||
from functools import partial | ||||||
from shapely.geometry import shape, mapping | ||||||
from shapely.ops import transform | ||||||
import pyproj | ||||||
|
||||||
def esri2geojson(esrijson_feature): | ||||||
def esri2geojson(esrijson_feature, srid = 'epsg:4326'): | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Python style is usually no whitespace around
Suggested change
|
||||||
response = dict(type="Feature", geometry=None, properties=None) | ||||||
|
||||||
geojson_geometry = convert_esri_geometry(esrijson_feature.get('geometry')) | ||||||
if geojson_geometry: | ||||||
if srid != 'epsg:4326': | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I think it might be out of the scope of this tool to reproject. Usually we ask the server to give us the data back reprojected (with the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @iandees Yeah the query API is the only endpoint that allows for |
||||||
project = partial( | ||||||
pyproj.transform, | ||||||
pyproj.Proj(srid), | ||||||
pyproj.Proj('epsg:4326'), | ||||||
) | ||||||
|
||||||
geojson_geometry = mapping(transform(lambda x, y: (y, x), transform(project, shape(geojson_geometry)))) | ||||||
|
||||||
response['geometry'] = geojson_geometry | ||||||
|
||||||
|
||||||
esri_attributes = esrijson_feature.get('attributes') | ||||||
if esri_attributes: | ||||||
response['properties'] = esri_attributes | ||||||
|
||||||
return response | ||||||
|
||||||
|
||||||
def convert_esri_geometry(esri_geometry): | ||||||
if esri_geometry is None: | ||||||
return esri_geometry | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's weird to have a wrapper function that is named the same as the function it's calling. Would it make sense to call this
reproject_and_convert()
or something instead?