New answers tagged

1

1) I just don't know how to convert .geojson file to .shp. This is a one of the bases of ogr Python. If you have a geometry, it is very easy to convert it to a shapefile # geojson is GeoJson Polygon from osgeo import ogr output = "geojson.shp" driver = ogr.GetDriverByName('ESRI Shapefile') if os.path.exists(output): driver.DeleteDataSource(output) ...


0

For points you can do it using CSS, in the layer you can use the pointToLayer function and return a DivIcon with the CSS class you want. Then the CSS has the rotation applied. See http://davetimmins.com/2015/10/07/Rotated-icons-with-leaflet/ for more details.


2

Where can I find data to produce these sort of visualizations? You're asking for administrative boundaries. How to get the official version depends on the country's administration. As far as I'm aware, a normalized dataset for all official administrative boundaries doesn't exist. IMHO the closest you might get to that is Natural Earth or OpenStreetMap. ...


1

There are now Python modules easier to use for that, as rasterio Rasterio employs GDAL to read and writes files using GeoTIFF and many other formats. Its API uses familiar Python and SciPy interfaces and idioms like context managers, iterators, and ndarrays. Therefore from Masking raster with a polygon feature in Rasterio Cookbook import rasterio ...


0

<html> <head> <meta charset=utf-8 /> <title>PipeGeoJSON Demo</title> <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' /> <script src="https://api.mapbox.com/mapbox.js/v2.2.4/mapbox.js"></script> <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script> <...


7

So the JSON you are using is just simple JSON not GeoJSON. The main difference is that the GeoJSON contains a geometry object you can read more about here in the GeoJSON spec. You can however convert your JSON to a CSV file and load it into QGIS that way. Go to a site like this one and put in the URL to your JSON. I plugged in "http://www.nanaimo.ca/...


4

It might be worthwhile looking at the CartoDB Import API. You can set up syncing a file from a URL with a simple cURL command. Check out the documentation and the example at this link. It may help get you started down the right track. OR While the import API is one possible method, it looks like you can sync GeoJSON if it is hosted on the web somewhere. ...


0

GeoJSON is just a file format. While it might often be downloaded from remote servers on-the-fly, there is nothing in the spec dictating that. You need to figure out how to save the file locally, then you can simply load it in QGIS.


1

I'd use the OpenLayers Format readers and writers. GML reader here http://dev.openlayers.org/apidocs/files/OpenLayers/Format/GML-js.html GeoJSON writer here http://dev.openlayers.org/apidocs/files/OpenLayers/Format/GeoJSON-js.html May be overkill to just convert from GML to GeoJSON, but OpenLayers API are widely used and tested, and also easy to extend. ...


0

I think this project may helps you. https://github.com/highsource/ogc-schemas. It is based on Node.js environment. but if you want to make use of it in client side, it is possible with Browserify(http://browserify.org/)


0

If your needs are stepping up from simple viewer to managing maps across sessions you should either build your own, or look into something offering that functionality out of the box. MapStore 2 for example offers this functionality (among several others) and it's open source: http://geosolutions-it.github.io/MapStore2/ There are other projects building on ...


2

Your data is stored in the features array. You can access that by specifying a custom datasource within the ajax property like this: "dataSrc": "features". I haven't found a way to get the GeoJSON property "type": "FeatureCollection" that way, it is outside of the actual data "rows". The complete code: $(document).ready(function() { $('#example')....


0

It is a basic Python json problem (How do I write JSON data to a file in Python?) from rasterstats import zonal_stats stats = zonal_stats("a_poly.shp", "test.tif",geojson_out=True)) # as the result is a json/geojson object import json # or geojson with open('newfile.geojson', 'w') as outfile: json.dump(stats, outfile) # or geojson.dump(stats, ...


0

TL;DR: yes you can, but why would you want to do this? You can just upload GeoJSON using JSON file using Firebase console and it technically works. The data can then be loaded using REST API, and you will get same GeoJSON as result of .json query. However, this is not very effective as you can query same dataset back, or refer specific object by index (e.g. ...


0

Okay so considering I have access to ArcMap, and this is a GIS forum, I found a temporary work around, its not ideal, but right now it puts labels on my map: I open the shapefile in ArcMap I Label the features (Obviously editing the label properties to my desire) I find a text size and zoom level that displays all of my labels effectively( no bunching, all ...


0

This is a follow up answer. The quick way to do it is to use a listener event and extract values for each polygon using event.feature.H.ATTRIBUTE_FIELD; So, in my case it ended up as the following? Cities.addListener('click', function(event) { var str = event.feature.H.NAME; infowindow.setContent(str); infowindow.setPosition(event.LatLng()...


1

I hit a similar problem. I just needed to find the valid records in my dataset (I discarded the records with Duplicate Vertices). I renamed the collection - db.myCollection.renameCollection('myCollectionBk') Then I added a single record from the original collection into a new collection and added a geospatial index to the collection db.myCollection....


2

I do not believe it's possible to limit the records retrieved from a geojson file. A complete geojson data structure is always an object, so if you only fetched a part of it (for example using an http range request) then you would get an invalid json syntax - missing either the opening or closing brace and the json would not be parseable by the browser. ...


1

I only want the few that should be displayed in the current bounding box Why? Unless there's a performance hit, you shouldn't filter the results - when you pan the map, you'll have to manually recalculate the visible points again. If there's a performance hit due to a large number of points, use some clustering/decluttering leaflet plugin first (these ...


0

With javascript you could write a filter, here is an example using jquery: http://stackoverflow.com/questions/23720988/how-to-filter-json-data-in-javascript-or-jquery


0

In your "working" code, you are missing the argument in teststyle() call. That may be just a typo? I guess you meant just teststyle (without parenthesis), i.e. just pass a reference to the function, not to its result after execution. In your example code, the teststyle function expects a feature (typically from an L.geoJson layer group) in order to read its ...


0

Based on the error, it appears that there is an issue with the variable type or referencing the variable. You may want to see this SO Q&A: JavaScript - Uncaught TypeError: Cannot read property 'search' of undefined The OP was able to troubleshoot based on one of the answers and found that using string() instead of toString() worked for them. i ...


0

Changing layer on zoom: Since you did not mention what tool you will use (Google Maps, Leaflet, ...) I will try to answer your question with pseudo-code. The principle of changing the layer when zooming is easy. You have different possibilities how to solve this. The simplest way of doing this is by "assigning" layers to zoom levels. This could look as ...


0

For instance how about using the ol3-popup plugin? Here you can define the html content of your popup. var map = new ol.Map({ target: 'map', layers: [ new ol.layer.Tile({ source: new ol.source.OSM() }) ], view: new ol.View({ center: ol.proj.transform([-0.92, 52.96], 'EPSG:4326', 'EPSG:3857'), zoom: ...


0

Im just wanting to understand my options for producing an offline map using Mapbox gl js. Mapbox GL JS is a library for rendering vector tiles as Mabox PBF files served over HTTP. In order to use it "offline", you'd have to come up with some way serving those files "offline". I'm using quotes because it depends a bit what you mean. If you just mean ...


0

In the end, it was an actual bug in version 0.9.6, an older version which I was using. Solution: git clone or ask for a newer version at least 0.9.8 beta. You can read more in the issue opened on GitHub.



Top 50 recent answers are included