Hot answers tagged

28

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 ...


22

I would suggest downloading and installing QGIS. You can then open the file that you link to and export the data in variety of formats. The most common format for spatial data of this type is a shapefile which is one of the files that you linked to (TM_WORLD_BORDERS_SIMPL-0.2.zip). The reason that it is a zipfile is that there are several associated files ...


20

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".


16

According to Mike Bostock (and other contributors to the TopoJSON extension): TopoJSON is an extension of GeoJSON that encodes topology. Rather than representing geometries discretely, geometries in TopoJSON files are stitched together from shared line segments called arcs. TopoJSON eliminates redundancy, offering much more compact representations of ...


9

Here's a link to Esri's doc on JSON geometry objects. From that page: The REST API supports 4 geometry types - points, polylines, polygons and envelopes. Sounds like multi-polygons are not supported. See below. You can create multi-polygons by adding additional rings. There's nothing explicit about interior v. exterior rings. I'm curious so I'm going ...


9

The problem is that your string inputFeature_json has special characters that are not in the ascii encoding. If you have characters that are not in the english alphabet they can cause encoding errors. Try to convert the string as unicode. for example: # Script arguments inputFeatures_json = arcpy.GetParameterAsText(0) #wtite to file jsonFileName = '...


8

Stick to a single where parameter in your query string. Here's an example of a where clause hitting multiple fields: http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/SanFrancisco/311Incidents/MapServer/0/query?geometryType=esriGeometryPoint&spatialRel=esriSpatialRelIntersects&where=address%3D%27875+HOWARD+ST%27+or+objectid%3D193510&...


8

I like @celenius' answer; however, another option would be to export the the World Borders Dataset to CSV using ogr2ogr. I just downloaded your preferred dataset and ran this command with ogr2ogr --note that your script should be a single string without any line breaks. I find them easiest to write in notepad with wordwrap turned on, then I copy them into my ...


8

You could write a simple script in (for example) Python that will process the data for you. import json from itertools import chain Open the file and read the data into a Python dictionary: isil = json.load(open('isil.en.json')) The points object is just a list of feature collections, so you can use the python itertools library to help chain the ...


7

It's fairly easy with urllib2. Say you've got a gigantic url like this: http://myserver/path/to/a/thing?json1={"data":[1,2,3,4,5]}&json2={"data":[1,2,3,4,5]}&json3={"data":[1,2,3,4,5]} All you need to do is take the query (everything after the ?) and jam it in the data argument to urlopen. import urllib2 import urlparse # GET return_data = ...


7

Solved by himself : Adding ?compression=false to the request query will output unencoded data. A proof that smeagol and gollum can work together. ( what is compression, my precious? )


7

Your generated GeoJSON is valid JSON, no problem. But, it's not valid GeoJson, as you can see here: http://geojsonlint.com/ The problem seems to be that the features-array in your featurecollection contains three features, two with geometry:none and one with just geometry (which is also string-encoded). So, in short: Your OpenLayers-code seems fine, the ...


7

Look at the samples on the specification site. You'll need to write a script in the language of your choice that will get you from [ {"date":"2014-09-25","time":"20:49:09","lat":"53.269","lon":"6.935","depth":"3.0","place":"Meedhuizen","mag":"1.5","type":"GH","last":"True"}, {"date":"2014-09-24","time":"23:49:36","lat":"53.351","lon":"6.693","depth":"3.0","...


7

You'll have to patch existing software in order to use such a format, but there's nothing wrong with embedding GeoJSON in other JSON formats. JSON is super extensible like this. Every object is its own namespace. If you look in the other direction, there are some applications, namely Leaflet, http://geojson.io, Fiona's command line programs, that will ...


7

Geotools as a support for geojson. See here. Otherwise, you could simply use a typical JSON parser (such as json-simple) together with the geoJSON spec, which is really easy to use. The best solution depends on what you want to do with the parsed information.


7

Because it's a "oneshot", you can do it manually (also possible running via Node) Open a JavaScript console in your browser. You need to loop to get an array of array of Feature (because each FeatureCollection have one or more Feature) Then, you will use the flatten function to transform the array of array into an array (a recursive function borrowed from ...


6

You can also see Esri's geojson-utils on Github that "contains [javascript] utilities for converting GeoJSON to other geographic json formats and vice versa. Currently only GeoJSON to Esri JSON has been developed. Also, note that only geometries in the WGS84 coordinate system are supported."


5

ESRI JSON to GeoJSON (for OpenLayers) *Likely to be modified for Leaflet javascript //create esri JSON object var myReturn = "esriObj = "+xmlHttpGet(restCall, false); eval(myReturn); I can now work with esriObj as a JSON object i.e. esriObj.geometryType. What happens in the xmlHttpGet method? Basically I create a XMLHttpRequest and pass in ...


5

You must use a geoJSON file (The GeoJSON Format Specification) and not a simple JSON file. Your example is not a GeoJSON file (no 'geometry' tag for example) As example, GitHub announced that you can now automatically view any GeoJSON files that may be in a repository inside an interactive map driven by MapBox technology (see my example AAC.geojson) And ...


5

I got it to work using Geoserver 2.3 and Leaflet with WFS 1.0.0 here. When I changed to version 1.1.0 and 2.0.0 it returned the same json object as 1.0.0 but neither rendered on the map. Not sure why and it's a bit beyond me. Here's what I'm using: var rootUrl = 'http://tomcat.capecodgis.com/geoserver/capecodgis/ows'; var defaultParameters = { ...


5

You cannot apply this particular example without understanding the JSON format: your external file "file.json" is not an .json file A correct format would be (without var states = [:) { "type": "Feature", "properties": {"party": "Republican"}, "geometry": { "type": "Polygon", "coordinates": [ [ [ -84.32281494140625, 34....


5

To parse or deserialize geojson in Java REST webservice, i prefere to use geojson-jackson , which integrate itself very nicely with jackson.


4

Check in Firebug (Firefox) or Fiddler (IE) if your file internet_users_2005.json.fixed is in fact being loaded. I suspect there's a problem with the path.


4

Leaflet and ArGIS vector layer. https://github.com/JasonSanford/leaflet-vector-layers Working demo. http://geojason.info/leaflet-vector-layers/demos/arcgis-server/ More on Leaflet and ArcGIS. Leaflet and ArcGIS Server layers i.e. AgsDynamicLayer and AgsFeatureLayer. You can get this fork which has support for ArcGIS server. https://github.com/...


4

Because Features to JSON outputs ArcGIS JSON geometries, you'd have to use something like Terraformer to convert to GeoJSON if you intended on working with the data as a client-side graphics layer in Leaflet. edit: 30/9/15 Esri's open source Leaflet plugins make it easy to fetch data dynamically from ArcGIS Server and ArcGIS Online and display in Leaflet.


4

It's not possible to do with pure JavaScript as it creates 3 binary files. Your best bet would be to setup a OGR web service that would take json in parameter and output a zipped SHP. Look at Ogre, it may help: http://ogre.adc4gis.com/


4

I am working on one here: https://github.com/morganherlocker/geojson2shape It is javascript, but it runs server side, which I would bet all of the solutions require. This one is essentially a node.js wrapper around ogr2ogr. It would be easy enough to set up a simple node.js server though that accepts geojson and sends back the url to a shp download (that ...


4

From @Mike Toews' tip: @Entity @Table(name="cities") public class City { @Type(type = "org.hibernate.spatial.GeometryType") @Column(name="the_geom") private Point theGeom; public String asJson() { GeometryJSON g = new GeometryJSON(); return g.toString(theGeom) ; } } You will need at least these JARs: gt-api-10.0....


4

Use the JSON Reader and then use a VertexCreator transformer. This transformer (which was previously called the 2DPointReplacer) will let you convert the X/Y coordinate values into a true spatial feature. Then you can simply write the data to your Geodatabase Writer. Make sure the Allowed Geometries field is set to geodb_point


4

This is by design, you are sending it a feature set and not a singular geometry. If you'd like the Geometry on its own, do this: import json geom = arcpy.AsShape(json.loads(json_string)["features"][0]["geometry"], True) We thought in many cases people would like to parse full Esri JSON feature sets and not just individual geometries, so that's why it ...



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