Tag Info

Hot answers tagged

15

GeoJSON here are the SPECs. Here's an example of a line and a polygon: { "type": "FeatureCollection", "features": [ { "type": "Feature", "geometry": {"type": "Point", "coordinates": [102.0, 0.5]}, "properties": {"prop0": "value0"} }, { "type": "Feature", "geometry": { "type": "LineString", "coordinates": [ ...


12

This works with the default "Add vector layer" dialog You'll have to add the bounding box to the query manually if necessary. It's also not difficult to import GeoJSON into QGIS. For an example covering point geometries see "Tweets to QGIS".


11

If you've got an GDAL/OGR dev environment (headers, libs), you could radically simplify your code by using Fiona. To read features from a shapefile, add new attributes, and write them out as GeoJSON is just a handful of lines: import fiona import json features = [] crs = None with fiona.collection("docs/data/test_uk.shp", "r") as source: for feat in ...


10

TileStache will definitely do it, specifically the PostGeoJSON provider in the extra providers collection. The main difference between this and what we did for the Polymaps examples is polygon clipping - after seeing how large Alaska can get at higher zoom levels, we clipped all the features in the Polymaps examples to cut down on load times and so on. We ...


9

One thing to note is that MongoDB's support for spatial datatypes is horrendously bad for any serious spatial lookup, and this applies across the board with NoSQL last time I checked. I dislike GeoCouch quite a bit less, but it also still has a way to go. GeoJSON is a fantastic format but to take advantage of the limited (POINT-ONLY) spatial indexes in ...


9

Try wrapping the features in the following: {"type":"FeatureCollection","features":[ ****ALL THE DATA HERE -- COMMA SEPARATED**** ]} and separating each feature with a comma. For example, here's the first two features from the IE dataset: {"geometry": {"type": "Point", "coordinates": [-6.422587, 53.293363]}, "type": "Feature", "id": ...


9

GML, http://en.wikipedia.org/wiki/Geography_Markup_Language KML, http://en.wikipedia.org/wiki/Keyhole_Markup_Language GML / KML difference http://en.wikipedia.org/wiki/Geography_Markup_Language#GML_and_KML


9

You Can use ogr2ogr. Simplest to install it would be to download fwTools. the following command will do ogr2ogr -f "GeoJSON" E:\lakes.geojson e:\lakes.gml Else if you have QuantumGIS, you can add your GML layer to map and by Right-Clicking the Layer, Select Save As to GeoJSON format.


9

Glad you asked, oh handsome OP. Steps For Mac OSX 10.8, assumes the installation of homebrew. Install node.js: brew install node.js Install topojson under node: npm install -g topojson Convert the data: topojson -o output_file.json input_file.json


8

If you're talking about GeoJSON you can use any kind of database, and backend server, you want so long as it: 1) Expects to receives TMS or /{zoom}/{x-coord}/{y-coord}.json style URLs and can convert Z/X/Y in to a bounding box. (Take a look at something like Tilestache (.org) if you want/need to see the math involved in doing that.) 2) Returns GeoJSON. ...


8

Here is an obvious solution to my own question - ogr2ogr! I'm not sure why I didn't think of it sooner. It has both PostGIS and GeoJSON drivers so this should work great.


7

OGR: ogr2ogr -f GeoJSON test.json "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Hydrography/Watershed173811/FeatureServer/0/query?where=objectid+%3D+objectid&outfields=*&f=json" OGRGeoJSON That command will read the query result directly from the URL. You can also supply it with a text file containing your JSON or you can directly ...


7

This is simply not true, "to take advantage of spatial indexes in Mongo, you'd need a spatially indexed collection holding nothing but a record for each of the polygon's points, with an additional value for the record ID of your spatial record living in another collection, then use a bounding box query to get record IDs from one [collection] and select ...


6

You should check out GeoJSON.Net by Vish: http://viswaug.wordpress.com/2008/05/11/geojsonnet-a-net-library-to-produce-geojson-output/ It should be pretty easy to extend it to use ArcObjects geometries. Also, you can take a look at the GeoJSON exporter I did for SharpMap (you'll have to Google that since StackExchange won't let me post a second hyperlink). ...


6

You want urn:ogc:def:crs:EPSG::26912 from the GML link on spatialreference.org. GML uses the URN syntax for describing coordinate systems. Alternatively, you could specify "crs": { "type": "link", "properties": { "href": "http://spatialreference.org/ref/epsg/26912/esriwkt/", "type": "esriwkt" } } or "crs": { "type": "link", ...


6

Just Drag'n Drop the file in qgis, be aware that Qgis doesn't support mixed types in the same file (point, line, poly) and it will open only the first type found. In the example bellow with your geojson file, I imported each type at a time.


6

Before going down any more laborious paths, the simplest option is to reduce the geometry. What are your source datasets? How did you simplify them? How much did this reduce the geojson file size? If you are confident that you have done all you can on the above, then the lowest hanging fruit of your options is Serve the geojson file gzipped, ...


6

Shapely deals with geometric objects, not features or collections of features. See the manual on shape(). Your code (with JSON) could be: import json from shapely.geometry import shape f = open('wijken.json', 'r') js = json.load(f) f.close() for f in js['features']: s = shape(f['geometry']) ...


5

You can always use an open-source tool like QGIS to open your shapefile and merge features using the built-in "merge selected features" tool (just select features, click merge, select attributes to inherit to the new merged feature, done). This of course doesn't make much sense if we're talking about hundreds or thousands of merges. I myself was wondering ...


5

OK - well I thought I had solved it. replace line ~80 of this file C:\Python26\ArcGIS10.0\Lib\arcpy\arcobjects\geometries.py from this: return {'type': 'Polygon', 'coordinates': [[(pt.X, pt.Y) for pt in part] for part in self]} to this (or something that is more concise and elegant and does the same thing): obj = {"type": "Polygon"} coordinates = ...


5

Unfortunately JSON is, much like XML, badly suited for stream processing so almost all implementations require that the whole dataset be loaded in memory. While this is ok for small sets in your case there is no other option than breaking the dataset into smaller, manageable chunks. Improving on Pablo's solution, here's one that does not require you to ...


5

To answer my own question on how to combine both the .dbx (properties) and the .shp (geometries) into a single JSON file: The problem I did not see is that all file names must be lower case to enable ogr2ogr to do the conversion. That should not be neccessary if your file system is case-insensitive but mine is. With this requirements fulfilled ogr2ogr is ...


5

OK, playing around with different projections, scales and translations in d3 solved my problem. Since the default projection when using d3.geo.path() is albersUsa there was good reason to try some other projections. I suppose the problem could have been solved easier using the right EPSG specification when converting the shape file but these obscure numbers ...


5

Happily OGR can do this for you as both ogr.Feature and ogr.Geometry objects have ExportToJson() methods. In your code; fe.ExportToJson() And since geojson FeatureCollection objects are simply dictionaries with a type of FeatureCollection and a features object containing a list of Feature objects. feature_collection = {"type": "FeatureCollection", ...


5

You have two ways of reducing the file size: Remove all the pretty formatting and redundant white space. In some 'XML-style' files this can be a surprisingly large amount and can easily double or even treble your file size. However I doubt it accounts for the difference in your volume and the data you link to above. Reduce the volume of actual data ...


5

I wouldn't call it a bug, just a matter of confusing and contradictory standards. When talking about geographic locations, we usually use Lat-long. This has been codified in the ISO 6709 standard. When dealing with Cartesian coordinate geometry, we generally use X-Y. Many GIS systems, work with a Geographic Location as a special case of a 2 D coordinate ...


5

Taking a look at the source code of PostGIS I found out how it parses SRIDs. Here is the correct way to specify the SRID in GeoJSON. The GeoJSON specification says that the coordinates of a polygon are an array of line strings. Therefore I had to wrap them with additional brackets. { "type":"Polygon", "coordinates": [ [ ...


5

why not use ST_GeomFromGeoJSON which takes as input a geojson representation of a geometry and outputs a PostGIS geometry object. ST_AsGeoJSON, the inverse see Creating GeoJSON Feature Collections with JSON and PostGIS functions or ST_GeomFromGeoJSON from OpenGeo. To convert to WKT, use ST_AsText , the reverse of ST_GeomFromText() which return the ...


4

I've definitely wondered about this myself as it's something I want to make use of in Tile5 (http://tile5.org/) also. I've seen Mike Bostock (who worked with Stamen to produce Polymaps) respond via Twitter on the topic before and here is the link: http://twitter.com/#!/mbostock/status/27659816563 Would definitely like to find a nice standalone solution to ...


4

ArcGIS 10 has the AsShape function for converting GeoJSON to arcpy geometries, which mimics Shapely's AsShape, and arcpy geometry objects implement the __geo_interface__ standard (also from Shapely) for getting arcpy geometries back as GeoJSON.



Only top voted, non community-wiki answers of a minimum length are eligible