I have a dataset that has four types of files with the following file extensions -
.DBF,.PRJ,SHP,SHX
My goal is to get all the polygon coordinates for each neighborhood and draw the boundary outline on the google map when a user is on a specific Neighborhood page. Currently the datasource for the site is a MySQL Database.
I have tried converting the shp file to Geojson but then parsing that file is time taking.
I have also tried using tools such as QGIS and shp2sql etc.
I would like to know what is the best way to get the main attributes from the dataset along with each neighborhood's Polygon coordinates.
please advise
I have managed to accomplish this using the ogr2ogr command line tool -
ogr2ogr -f "MySQL" MYSQL:"mydb,host=myhost,user=mylogin,password=mypassword,port=3306" -nln "world" -a_srs "EPSG:4326" path/to/world_adm0.shp
I have the polygon coordinates in a geometry field in the table attached to its corresponding neighborhood id.
I did Select ASTEXT(Shape) as POLYGON from world to get the array of coordinates and now I can convert that to json and send it to Javascript so that it can be mapped
Related
Using PHP, we have an array of GPS coordinates that create a specific route.
I need to allow the user to give an input width. Using this input we need to create a polygon around the line.
In the image found under the link below:
https://drive.google.com/file/d/1DmVdKAh6advlcQYiDZQPsKYisjxmPu5I/view?usp=sharing
We are given the latitude and longitude of the points A,B,C. I need a way to get the coordinates of the points D,E,F,G,H. Note that these are GPS locations and not 2d formulas
I am using Google Maps to display locations stored in a MySQL database containing name, latitude and longitude information. An AJAX request is sent and the map is updated with all the locations. So far, so good.
Users have the ability to filter the locations by drawing polylines on the map to create a bounding box. The idea is that only locations within this bounding box are returned and they can draw whatever shape they want.
All the points used to draw the shape are returned a list of coordinates. Where I am struggling is taking the list of coordinates and finding everything within them. Can I achieve this with an SQL query? Is it even possible?
I have seen examples of returning locations within x radius from one set of coordinates and also a square box, but I have no idea how to take that further and get everything within a potentially infinite set of coordinates.
You should transform the shape the user enters into a polygon. Then you transform all locations within a square around this polygon into the same coordinate system.
Using a solution describe in the wikipedia page for point-in-polygon problems you will be able to find all locations within this shape and remap them to coordinates in your sql database and then into locations.
There are however similar question which might help you find a proper solution to your problem. See:
How can I determine whether a 2D Point is within a Polygon?
Point in Polygon Algorithm
I'm using Thomas Bradley's signature pad (http://thomasjbradley.ca/lab/signature-pad/) to capture signatures on the web. It is pushing to a filemaker database as JSON coordinates.
Is there a way to store that JSON coordinates as an image on a Filemaker Database?
Or alternately, is there solution that allows coordinates to be processed as an image for pdf forms?
p.s. I've tried including the php signature-to-image.php file that is on the tutorial page, but it was giving me an error on 58 of the code from that file itself. Not sure if that would have converted the coordinates for storing in database that way.
Similar issue to:
Extract X&Y coordinates
I have imported few shp files into PostGIS/PostgreSQL DB. Now I want to display the same on the OSM map using OpenLayers. As there are millions of records for the selected county, I want to only fetch those geometries that are within the viewport of the map in the browser.
Also, how should I fetch this data into the map? Is KML a good option? I am using PHP at the backendn and would like to know if I can use it instead of installing a geo server.
I have tried to find an example on the net but couldn't find any. Please help.
Look at the BBOX Strategy for getting stuff within a bounding box. Then look at Vector layer for getting them on the map. I don't have an example right now, but if I find one I will complete my answer.
You can use PHP to process the answers if you want to keep it simple. Just use a PHP page as datasource for the layer, and with the BBOX strategy you will always get info on the bounding box and the PHP page can get the correct features.
I'm working on a PHP application that needs to obtain data from a topographical map (different elevations denoted by different colors). I need to do two things:
Using this map (800x600), find a way to determine the exact pixel location of a particular city. For example, San Francisco is located at precisely 121x585.
Using the location from (1) above, I need to read the exact color at that location.
Note: The map provider does not provide location-based data, only a colored map. I suspect multiple libraries would be needed to map coordinates to locations on the map (via a ratio?) and then use OCR to read the color.
Are there any PHP libraries/tools that do this? How would you pull this off?
Once you know the pixel-coordinates, you can use PHP's built-in GD library to sample the color of an arbitrary pixel quite easily.
The tricky bit will be determining the pixel to sample, which can get pretty darned tricky. The earth being sphere-like, maps use various projections to produce a 2-d representation. If you know how the colored map image is projected, and you know the latitude/longitude of the pixel at (0,0), you should be able to write a function to convert lat/long to a pixel coordinate.
I may not have understood the problem entirely, but you should map the locations you want into an array (of objects?)
$city_mapping = array(new City("San Francisco", 121, 585), new City....); //Map your cities to an array.
Where City should be defined as a class to contain those variables.
Then use imagecolorat() to check for the color.