Web-based conversion shp to json - json

I'm currently working on a school project that implements Google Maps overlayed with data stored in shapefiles and a xml file with a bitmap in it and the WGS coordinates where the image should be overlayed.
The web application that needs to be build requires that a user uploads these raw files, and the result should be visible in the Google Maps.
Is there any way to convert these shapefiles to .json, using PHP or javascript, and get the coordinates stored in the .xml file to get the WGS coordinates. This needs to be done web-based, so stand-alone tools and software won't be sufficient.
These coordinates and .json files than need to be stored in a database, and these records will be used to put on the Google Maps with the appropriate overlays on the resulted coordinates.
Thank you in advance.

All of the processing will need to be done on the server side. I was able to find a shapefile reader class written in php here,
http://www.phpclasses.org/package/1741-PHP-Read-vectorial-data-from-geographic-shape-files.html
It sounds like you have a pretty decent handle on how you need to go about solving the rest of the problem from there.

js-shapefiles-to-geojson script renders shapefiles and dbf files entirely on the client-side, in the browser.
repo: https://github.com/wavded/js-shapefile-to-geojson
demo: http://wavded.github.io/js-shapefile-to-geojson/

Related

How to generate GIS Maps without any browser specific library?

I need to generate a GIS map showing some points and polygons. This map generation process has to run in the background so that every day at a certain time of the day a map is made and stored at a certain location in the file system.
I don't think leaflet can be used for this as it runs on the browser.
Not sure how will this happen in QGIS also....any light in this direction will be helpful.
My requirement is to generate a HTML report which contains a map. I cannot do it on the browser because the user will not use the browser and want the report to be inn his mailbox every day automatically.
I will be using node js to generate HTML.
How can this be achieved? Please save my life.
Thanks
I suggest you use something like phantom.js to perform what is essentially a screen capture of the map you generate in a web page that is 'displayed' on a headless, off-screen web page. What sort of map server you use to generate the maps is up to you; but that would let you capture a browser view of the map and re-package it in a PDF or an image that is embedded in an email.
Make that PDF or image a GeoPDF or a GeoTIFF or example and the result would retain some geospatial aspects instead of being a dumb screen capture.
I would use something capable of delivering a map tiling service (like wms) which you can then query server-side and piece together the tiles. I've had good luck with geoserver (http://geoserver.org/) but there are other solutions as well. I'm not sure if you can can query Google maps api or Open Street Map like this. The nice thing about your own map server is that you can completely define the map you want on it in one place. Aside from this, I would browse the npm repository to see if anyone has tackled this problem before.

google maps: How to create static images containing lots of GPS path points

I need to create images of GPS paths on top of google maps satellite information. The ultimate goal is to import those images in a report that is being created in an Excel program that is run through userforms & VBA.
I'm having trouble coming up with a way to automate the generation of these images. Preferably the user would not have to install additional software and there would be a way of automating this process using VBA. I would like to use the Static Google Maps API, but that is limited by the number of characters in an HTML request (2048 as I understand) and my path data is easily going to exceed that length.
Let's assume for now that I have a single KML file with my GPS path data.
Any thoughts on a way to convert large KML path files into static maps image files using VBA? I'm imagining VBA opening a local HTML file with a dynamic google map, uploading the KML file, and somehow capturing and saving a screenshot of the KML data loaded onto the dynamic google map.
FYI I'm locked into using the existing Excel/VBA forms-based program to generate these reports.
(new to this board and relatively new at programming so please let me know if my description is lacking. thanks)

Given list of countries draw map with those countries a different color

Looking to the do what the title says - produce a world map image that colors particular countries. I'm open to platform - Processing or Python/Basemap preferable. Web based service ok if it has an API.
Anyone have direction on this?
have you looked at GIS? There are a number of open source and free clients that allow you to work with various maps (probably .dwg) with various corresponding data in xml format to produce geographical visualizations through queries and you can export a number of formats. I think this would give you either the visualization that you want or the data to plug into processing or whatever to create it.
Get the map data in shapefile format, look at python bindings to OGR and GDAL, or maybe try Fiona: http://sgillies.net/blog/1095/fiona/ or SciPy, or just download Qgis www.qgis.org and learn some GIS skills.
Country-level shapefiles for the world are fairly widely available www.gadm.org maybe.
Google Geomap did the trick here.
It's part of their chart visualizations tools. A javascript call that returns an SVG map colored according to data that you provide.

Getting KML layer to work locally (e.g. the Google TooManyMarkers Example)

I have copied all of the files for the Google example http://gmaps-samples-v3.googlecode.com/svn/trunk/toomanymarkers/toomanymarkers.html to my PC, but the KML layer does not appear when I tick the checkbox.
The files I copied are:
functions.js
markers.js
markers.kml
toomanymarkers.html
I have also copied these to http://www.performit.co.uk/misc/maps/toomanymarkers/toomanymarkers.html and it doesn't work there either.
Am I missing something? Do I need to have an environment set up for the files to load?
The KML file must be publicly accessible via the web, so this will not work if you are developing locally. Google accesses and processes the file, returning that data as location, zoom level, markers, polylines, polygons, etc.
What is the actual URL to your KML file? Copy that, and past it into the Search Maps box of GoogleMaps. If it's valid KML, GM will process it and display your KML data.
It appears to be a web server configuration issue. When I try to access http://www.performit.co.uk/misc/maps/toomanymarkers/markers.kml, I get a 500 server error. It appears to me that functions.js tries to access that URL. So, I'd look into that. By comparison, http://gmaps-samples-v3.googlecode.com/svn/trunk/toomanymarkers/toomanymarkers.html happily serves up the KML file.

How to improve KML performance

Hi
I'm having some issues with KML performance. At some times the KML markers only appear after a reload which may have to do with google caching the results. I think a better solution is needed perhaps something like displaying a total of markers for an area on a larger zoom level and then more detailed for levels that have more zoom. Is such a solution feasible and if so, how? Can you think of other ways how I can improve performance of my KML map? The links are http://www.koolbusiness.com and the KML file is http://www.koolbusiness.com/list.kml
I can load the KML file into maps.google.com with no problem however when trying to display it on my custom map the display sometimes won't load.
Thanks in advance for any suggestions.
UPDATE: I've updated to using a KMZ file with zip compression. The file is available via http://www.koolbusiness.com/list.kmz and the source and more info is available at http://montao.googlecode.com
don't know if it affects performance but it seems like you need to configure the mime types for kml files.
http://code.google.com/apis/kml/documentation/kml_tut.html#kml_server
Have you tried to compress the kml files as kmz files? You can do this with a zip program and just call the file kmz.
You repeat the style element in the placemarks but you can also create them under the doucment element and then just reference them with an id. http://code.google.com/apis/kml/documentation/kmlreference.html#style
I'm not sure if you've changed the KML yet to conform to some of the previous suggestions but...
The KML File seems to be pretty minimal which is good. I was going to suggest truncating the decimal points on the lat/lng.
You can compress like KML file to KMZ like the previous poster has mentioned. More information can be found here: http://code.google.com/apis/kml/documentation/kml_tut.html#kml_server You'll need to set up the KMZ MIME type on your server too.
You can reduce the amount of white space in your KML file. It seems to have additional spaces when not required...
You can configure your web server to send cached versions of the KML file... I'm not sure what kind of back end you're running though so I can't really give pointers. This might be a reason why the markers don't show. Google's server will time out your request if it takes too long.
As for your question about a solution to displaying total markers in an area for a zoom:
I was thinking you could for each zoom level, check the boundary of the map and then only display markers that have coordinates in that boundary. You'd probably have to write some kind of function that checks if it's in the boundary. I don't know of any way to retrieve the markers from the KML file as objects unless you manually parse the KML yourself using a client side parser.
To help determine why your markers don't load, try using FireBug to determine the requests to Google's servers. And see what kind of response is returning which might lead to more answers to your problem. I believe the one you should look for is KmlOverlayService.
Hope that helps.