How to get from tmap the latitude longitude of each x,y point on the World map? - latitude-longitude

With the library tmap, a map can be plotted of the world coastlines and borders:
library(tmap)
data("World")
tm_shape(World) + tm_borders()
Is it possible to get the latitude longitude of each x,y point on the map that is used to draw coastlines and borders?
If not, is such a set of data with latitude longitude points of the world map to draw coastlines (and borders) available elsewhere?

You can do it in the following way:
library(sf)
library(tmap)
data("World")
tm_shape(World) + tm_borders()
Test <- st_union(World)
tm_shape(Test) + tm_borders()
Test_coord <- st_cast(Test, "MULTIPOINT")
tm_shape(Test_coord) + tm_dots()
There are some lines and points in the file that are not coastal lines. I think that is so because of some problmes in the World object, so condier using a different shape file.

Related

Why do we use crs.PlateCarree() instead of crs.Geodetic() when using Matplotlib and Cartopy to plot a map based on lat and lon?

I've been learning how to use Cartopy and Matplotlib to plot map. But I have a question regarding the argument transform. According to the Cartopy document, transform specifies "what coordinate system your data are defined in". Suppose I am going to plot temperatures of an area, and the area has been split into several grid cells. Each grid cells has a corresponding coordinate defined in lat and lon (Geodetic Systems). Based on the Cartopy document, I need to use crs.PlateCarree() instead of crs.Geodetic(). I'm a bit confused about it. Because,I think the PlateCarree is a way of projection. In other words, coordinates defined in PlateCarree projections are projected data. But latitude and longitude should be unprojected data. Can anyone help me with it? Thanks!

Nearest points to an edge within a distances using osmnx in Python

I'm trying to associate a set of points (lat, long) to an edge using osmnx library in Python.
I would like to find the nearest points to an edge within a distance x.
I have an edge and I would like to draw a circle and count how many points are into the circle, with a given radius. I have tha lat and long coordinates of each point but I don't know how to calculate the lat, long coordinate of the edge. I also have the coordinates lat, long of the nodes connected by that edge.
Thank you for your help.
import pandas as pd
from shapely.ops import transform
from functools import partial
import pyproj
from shapely.geometry import Point
mid_point = Point(lon,lat) # UNPROJECTED CO-ORDINATES OF MID-POINT OF AN EDGE
node_point = Point(lon_node, lat_node)# UNPROJECTED CO-ORDINATES OF THE NODE
x = 500 #DISTANCE IN METERS
#TRANSFORM INTO PROJECTED CO-ORDINATES
project = partial(pyproj.transform,pyproj.Proj(init='epsg:4326'),pyproj.Proj(init='epsg:3112'))
mid_point_projected = transform(project, mid_point)
node_point_projected = transform(project, node_point)
#CREATE BUFFER CIRCLE WITH DISTANCE X METRES WITH CENTRE AT EDGE MID-POINT
buffer_circle = mid_point_projected.buffer(x)
#PERFORM POINT-IN-POLYGON ANALYSIS TO CHECK WHETHER THE NODE FALLS WITHIN THE BUFFER CIRCLE
print(buffer_circle.contains(node_point_projected))
POINTS TO BE NOTED:
EPSG Geodetic Parameter Dataset is a structured dataset of Coordinate Reference Systems and Coordinate Transformations, accessible through this online registry (www.epsg-registry.org)
EPSG 4326 represents World Geodetic System (WGS84) (https://epsg.io/4326)(points on the Earth's surface represented in terms of latitude and longitude)
I have transformed it into EPSG 3112 representing GDA94 / Geoscience Australia Lambert (https://epsg.io/3112). You should transform it into the corresponding EPSG code for your study area.

What a set of GPS coordinates means?

I have a set of GPS coordinates 12.9611159,77.6362214. What exactly do these mean? How can I convert them to degrees of longitude and latitude? What formula should I use to get accurate distance between two sets of coordinates when the order of distance is 10km.
Most likely 12.9611159 is the latitude in degrees, 77.6362214 the longitude. In that case, the coordinate is in India. If latitude and longitude are reversed, you end up in the Greenland Sea.
You can easily check this by entering the coordinate pair in the Google maps search box. Google expects latitude first.
For the distance, in python you can easily use the haversine package:
from haversine import haversine
my_coord = (12.9611159,77.6362214)
other_coord = (12.9, 77.6)
distance = haversine(my_coord, other_coord)
This will give you the distance in km.

How can I turn MapPos/(long,lat) into Pixels under Nutiteq?

I have deeply read the Nutiteq Api Reference and I haven't found built-in Methods to get the pixel representation of longitude and latitude on a device. There is nothing under the existing Projections, so I don't know how I could overcome this issue.
What I want to make is drawing a circle for my actual GPS Location like this,
NOT like n-vertices Polygon in HelloMap3D.
Getting Pixels of lat, lon and radius given Zoom Levelunder a given Projection is the Challenge because the rest would be calls like this
...
canvas.drawCircle(longitudeInPixel, latitudeInPixel, radiusInPixel, this.paintStroke); // <- For blue circunference
canvas.drawCircle(longitudeInPixel, latitudeInPixel, radiusInPixel, this.paintFill); // <- For blue translucent circle
...
So, how could I turn lat, lon and radius into their pixel representation under Nutiteq?
I thank you all in advance.
MapView has worldToScreen() method for this, see Map Calculations page in the Nutiteq Android demo project wiki.

Is there a way to convert actual street map coordinates to a set of GPS coordinates?

I wonder is there a way to convert actual street map coordinates to a set of GPS coordinates. I was thinking if I have a set of GPS coordinates on the corners of a rectangular street map, I could virtually put a GPS coordinate to any point in that area. It is logical but I am not sure how to do it.
The Geotools Java project has all the tools you need to transform from one coordinate system to another. I'm not aware of anything similar in C++ though I'm afraid.
There are an absolute wealth of coordinate systems out there (see: http://en.wikipedia.org/wiki/Geographic_coordinate_system), so you'd need to be more specific about the format in which you have your street map coordinates for me to give any more detail.
I think I get the concept. You need two ingredients for that:
1. Scale and..
2. Corner sample.
It's easy to make a program to offset your marked points on the map
but these requires the "Scale" (ex. 1-inch : 121001-meters) and the
sample of "coordinate" in at least one of any of the four corners
(top-left,top-right,bottom-left,bottom-right) for use to offset and
get.
Out of these variables needed, we could easily extract to get the
coords marked on your map.
MAJOR EDIT:
(Note: Disregard what I've written earlier above)
Variables:
mw = 2d mapwidth
mh = 2d mapheight
x = your 2d x coordinate
y = your 2d y coordinate
lat = latitude (our N or ?)
lon = longitude (our N or ?)
Formula:
lat = 180 + ( (x / mw) * 360) )
long = 90 + ( (y / mh) * 360) )
Explanation:
Following the formulas which are used:
x = (mw) * (180 + latitude) / 360
y = (mh) * (90 + longitude) / 180
I've personally transposed the formula above to find our latitude and longitude.
I hope this solves your problem and this is the appropriate answer for your question.
Don't forget to up my answer to save my honor from the humiliation earlier. jk. :)