Is there a way to divide a map into square grids and retrieve latitude/longitude information from there? [closed]
Asked Answered
S

2

7

I have a map of a specific area and I need to determine whether a given location -with lat-lon coordinates- falls into any grid that covers this map.

I decided to divide the map of the area I was given into 1 km x 1 km square grids using Google Earth -enabling the square grids using CTRL+L and zooming to the appropriate scale so that the grid lines are 1000 meters away from each other- and extract the entire data as KML, in order to get the latitude and longitude values for the corners of every single grid in my map and do a lookup from there -to see if the given lon/lat falls into any square grid and if it does, which grid etc.- but I don't know if this can be done -if Google earth allows me to extract its own square grid coordinates in KML format-.

Can someone provide any information about whether this is possible, and if possible how it can be done?

Seiler answered 20/8, 2012 at 20:15 Comment(1)
can you please tell me how you did it. Please write to me at niraula.a@gmailRappel
W
2

Consider for example the area that is between latitude 89N and latitude 90N (the north pole). The earth's circumference at latitude 90N is 0, hence, this the total area is circle-shaped.

It is not possible to divide any part of a sphere or an ellipsoid surface into non-overlapping, adjusting rectangles.

Wall answered 21/8, 2012 at 6:39 Comment(4)
True. But is there a way to do that with approximate square grids? Exact coordinates don't exactly matter due to the spherical/ellipsoid surface like you said, I just want to divide the map of my area into the square grids. -By the way, the area is between 36N and 42N-Seiler
Yes. Just increase the latitude and the longitude by 0.01 degrees or so at each step.Wall
By the way, I just thought of doing this via PostGIS so that I can query the database directly only by passing coordinate parameters from C++, is it possible? I asked it out here: stackoverflow.com/questions/12066168Seiler
I'm not familiar with PostGIS, but if I understand your problem correctly, all you need to do to find the grid-cell is something like idx= floor((Lat-36)/0.01) (assuming 0.01 is the resolution and you're indexing grid-cells wherer [0]=36, [1]=36.01, etc).Wall
H
0

Not quite sure if this is what you are asking or not, but you can get the latitude and longitude of the Current View of the globe.

var view = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
view.getLatitude();
view.getLongitude();

Here is some more information about the current view and the camera: https://developers.google.com/earth/documentation/camera_control

Happily answered 20/8, 2012 at 22:11 Comment(1)
Thank you for your answer, but I was looking to divide my map -a particular area- into 1 km x 1 km square grids and get the corner coordinates -the latitude and longitude values- of every single grid in order to determine if any user input -lat and lon- falls into a grid and if it does, which grid. I was wondering if I could do that -by that I mean retrieve the corners of grids- and export those values into a KML file in order to parse it from C++ end.Seiler

© 2022 - 2024 — McMap. All rights reserved.