Tag Info

New answers tagged

1

The problem with your solution is that source_srs is not a valid osr.SpatialReference(). If the result of source_epsg is 4269 then: source_srs = osr.SpatialReference() source_srs.ImportFromEPSG(4269) gives a valid osr.SpatialReference() NEW If I understand correctly your question, you want to use Leaflet, and Leaflet expects coordinates and GeoJSON ...


0

Since you have not specified any path, Python will put your file in the same directory as the Python EXE. This is not good practice. It is much better to specify a known path. You could maybe pick that up from some environment variable to make it relative to the project or hard code a proper path into your python e.g.: ...


1

You have many solutions but you choose to use ogr and the GeoJSON format (you could have chosen Fiona and shapely or one of the many modules to parse gpx files: Pypi:gpx or to parse XML files). 1) Is there a more direct or idiomatic way to create this rectangle? ogr is is verbose, look at Python GDAL/OGR Cookbook With the GeoJSON format: import json ...


0

here's a slightly modified version of your code. my changes are in the main loop and I made it such that you iterate over all features. I did not execute it so I apologize if there are any syntax errors! #coding:utf-8 import glob import ogr import json import numpy import matplotlib.pyplot as plt # 1) Is there a more direct or idiomatic way to create ...


1

For the sake of completeness. I believe this should be a comment on Regan response. But since I don't have enough reputation I'll leave it as a response. The DXF writer supports 2.5D layers, and given a line input, should output a 3D linestring on dxf. In the case of input POLYGONS you have to be more careful, since the driver defaults to generate a dxf ...


2

Stepping back, if you have data in PostGIS and you want to render it with Mapnik you really should be using Mapnik's native PostGIS support - aka mapnik.PostGIS datasource in python (https://github.com/mapnik/mapnik/wiki/PostGIS). That will be faster and more efficient than going through OGR. That said, if you have a good reason for connecting to PostGIS ...


2

Turns out it is as easy as this: MIMETYPE "application/json; subtype=geojson; charset=utf-8" Without the setting, no content encoding is returned by the server.


2

Depending on your version of mapnik, yes it's possible. Mapnik 2.1 introduced the Python Plugin as a data source. You would need to subclass mapnik.PythonDatasource and implement a features method that based on an incoming mapnik.Query object will return mapnik.PythonDatasource.wkb_features objects. For example: import mapnik import ogr class ...


2

You on Linux? If so, switch all the single quotes for double quotes and vice versa like this: ogr2ogr -f GeoJson -where 'neighborhood IN ("Lower East Side", "Greenwich Village", "Columbia St", "Financial District", "Flatiron District", "Williamsburg", "West Village", "Central Park", "Upper West Side", "Navy Yard", "Gramercy", "Stuyvesant Town", "Upper East ...


-1

That does not seem as valid geojson according to http://geojsonlint.com/. You should remove the last comma and add ]} to what you posted.



Top 50 recent answers are included