I have mapinfo file and spatial type is point. I want to know longitude and latitude but in this file not include field to specific describe to longitude and latitude.
the CRS is WGS 84/UTM zone 50s (EPSG:32750). I have to export the file (.tab) using ogr but the result is not like a longitude and latitude.
this is the result:
POINT (238339.99924633466 9640080.0006718487)
POINT (238540.00219973351 9640080.0006718487)
POINT (238559.99837215125 9640080.0006718487)
POINT (238580.0027904133 9640080.0006718487)
If I want to get the longitude & latitude from this file is posible?how can?
You will have to run those points through a conversion to get a "normal" (cartesian) latitude and longitude coordinates from them. OSGeo.org has several libraries available to convert these points and translate them to global latitude and longitude points. FreeGIS.org also has a list of tools that you can sort by language. I believe that "Geo" people prefer to use longitude, latitude when describing points.
POINT( longitude latitude )
Related
I am struggling to find a systematic way to convert coordinates and geometries to km.
Let's say I have a .shp file, which I read with st_read. I want to draw a circle of radius 10 kms around a city. I know the coordinates of the city in latitude and longitude, so I can convert to km with:
y = 111.2 * latitude
x = 111.2 * longitude * cos(pi / 130* latitude)
And then define a circle centered in x,y. Now I can easily draw the circle with plot.owin {spatstat.geom}, but, how can I plot is onto the geometry of the .shp file? Can I use st_crs to set the coordinates of the circle to the reference system of the original map (and how)?
I have dowloaded data from the HRRR, similar to the grib2 file from this notebook:
https://nbviewer.org/github/microsoft/AIforEarthDataSets/blob/main/data/noaa-hrrr.ipynb
I now wish to use the data for specific Longitude, Latitude. But I do not know how to convert my (Longitude, Latitude) to the grid coordinates in the matrix data.
The notebook mentions that “the HRRR data comes in the Lambert conformal projection.” (See cell 8).
I have looked at the GMT package, and they seem to handle the Lambert conformal projection: https://docs.juliahub.com/GMT/EoU0j/0.30.1/proj_examples/.
But how can I convert the coordinates?
The following code seems to convert, but I don't think this is for Lambert, and after looking at the GMT documentation, I am not able to adjust the settings in the command.
lat=37.0; lon=-119.0;
gmt("mapproject -J+proj=merc", [lat;lon])
Vector{GMTdataset} with 1 segments
First segment DATA
Global BoundingBox: [-1.3247019404399555e7, 4.118821159351122e6]
First seg BoundingBox: [-1.3247019404399555e7, 4.118821159351122e6]
2×1 Matrix{Float64}:
4.118821159351122e6
-1.3247019404399555e7
I found out that the longitude and latitude were actually in the grib file, so there is no need to convert:
using GRIB
f = GribFile(grb2_filename)
lons, lats, values = data(Message(f))
# lons in range [225.90452026573686, 299.0828072281622] = [-134.09547973426314, -60.91719277183779]
# lats in range [21.138123000000018, 52.61565330680793]
So we can just look for the indexes of the closest longitude and latitude, and read the corresponding value in values.
Since lat and lon degree both approximate to 110 kilometers, I will just minimize the distance as follows:
(min_error, coord) = findmin(abs.(lats .- lat) .+ abs.(lons .- 360 .- lon))
(0.020456228700048484, CartesianIndex(269, 548))
values[coord]
294.8936767578125
While this actually does not answer the title question, it answers my current need and perhaps will be useful for someone else.
I am working with a dataset that features chemical analyses from different locations within a cave, with each analysis ordered by a site number and that sites latitude and longitude. This first image is what I had done originally simply using ggplot.
Concentrations mapped by color over map
But what I want to do is use the shapefile of the cave system from which the data is sourced from and do something similar by plotting the points over the system and then coloring them by concentration. This below is the shapefile that I uploaded
Cave system shapefile
So basically I want to be able to map the chemical data from my dataset used to map the first figure, but on the map of the shapefile. Initially it kept on saying that it could not plot on top of it. So I figured I had to convert the latitude and longitude into spatial coordinates that could then be mapped on the shapefile.
Master_Cave_data <- Master_cave_data %>%
st_as_sf(MastMaster_cave_data, agr = "identity", coord = Lat_DD)
This was what I had thought to use in order to convert the numerical Latitude cooridnates into spatial data.
I have a set of coordinates that I want to turn into an angle and do some Anova analysis. I used maptools trackAzimuth function to do it, but I keep losing one or two points. I assume it calculates angles between two coordinates. But I want 1 point (angle) on 1 latitude and longitude, for example at [-80.222, 30.555 to 45]. Since my longitude is in North America, it is in a negative value, do we have to convert into positive before converting it into angle? Please enlighten me on this. Following is my data;
Longitude Latitude
-104.952 39.71478
-104.952 39.7149
-104.54 39.7148
-104.955 39.70441
-104.966 39.7175
My codes:
setwd("C:/Users/data")
install.packages("maptools")
library(maptools)
data <- read.table("data.csv", header = T, sep = ",")
dfr<-data.frame(data[3:4])
angle<-data.frame(trackAzimuth(as.matrix(dfr)))
My results is:
Angle
-81.001
-95.57075
-175.254
-32.628
Here, I lost 1 latitude and longitude. And my angles are negative, I want positive angles on this. How do I do it? Please help.
Thanks
Lets assume we have a point (described by latitude and longitude) (WGS84) and we form a SpatialPointDataFrame (gData.init). I would like to change the projection (transform) and then use the planar coordinates to estimate distances and intersection points using simple line-point methods. I use the following code to perform the transformation.
library(rgeos)
library(sp)
longitude = 22.954638
latitude = 40.617048
gData.init = data.frame(longitude,latitude)
gData.init$id <- as.numeric(rownames(gData.init))
coordinates(gData.init) <- gData.init[c("longitude", "latitude")]
proj4string(gData.init) <- "+proj=longlat +datum=WGS84"
gDataIn2100 <- spTransform( gData.init, CRS("+init=epsg:2100") )
Now I want to save the coordinates in any data type object; when I do this using the following code
gDataIn2100#coords
I get maximum one decimal:
longitude latitude
[1,] 411425.8 4496486
However when I print coordinates (I like lets say my coordinates to be more precise)
print(coordinates(gDataIn2100), digits = 12)
Then the resulting coordinates are somewhat different:
longitude latitude
[1,] 411425.810118 4496486.37561
This I think causes different estimation of minimum distances between a line and my point in case of using gDistance and by estimating the distance using LinkPointMinDistance
What do I do wrong?
DataIn2100#coords is equivalent to print(DataIn2100#coords, digits = getOption("digits"))
The decimals are only dropped when rendered to the screen. They are stored as numeric and have the precision of a floating point.
Note that coordinates(DataIn2100) is the recommended way to get the coordinates.