Comments (4)
Basically, but I think it depends on the zoom as well.
We do:
defaultRadius <- 0.0225
if (!is.null(zoom)) { # We enter this statement since we are not in the app
radius <- geosphere::distm(x = c(city[["long"]], city[["lat"]]), y = c(city[["long"]], city[["lat"]] + defaultRadius * (1 / zoom)), fun = geosphere::distHaversine)
} else {
radius <- geosphere::distm(x = c(city[["long"]], city[["lat"]]), y = c(city[["long"]], input[["osm_bounds"]][["north"]]), fun = geosphere::distHaversine)
}
cropped <- data.frame(lat = city[["lat"]], long = city[["long"]]) |>
sf::st_as_sf(coords = c("long", "lat"), crs = 4326) |>
# sf::st_buffer(dist = radius) |> # see https://github.com/r-spatial/sf/issues/1692
s2::s2_buffer_cells(distance = radius, max_cells = 5000) |>
sf::st_as_sf()
So in coordinates the view box (cropped
) is [xmin: city[["lat"]] - defaultRadius * (1 / zoom), xmax: city[["lat"]] + defaultRadius * (1 / zoom)] and the same for ymin and ymax but then with long. However, we do not use the default radius directly but compute a radius (I believe in meters) based on the location on earth (geosphere::distHaversine
). Then we get the actual view box.
from rcityviews.
I think the defaultRadius
is measured in geographical coordinates (i.e., degrees lat / long).
from rcityviews.
So if coordinates are X,Y (with decimal parts), then radius is (X+/- defaultRadius) and the same for Y?
from rcityviews.
Thank you forn in-depth explanation. Now I understand why zoom > 1 is faster than zoom < 1.
And thanks for pointing to distHaversine
function!
from rcityviews.
Related Issues (19)
- Generated images lack osm attribution HOT 1
- [Feature] Specify both city and country HOT 1
- Cannot map Tokyo HOT 3
- Control Over Text Size HOT 2
- [Feature] Way to obtain/save data only so it's quicker and more effective to try out different plot styles afterward HOT 1
- [Feature] change pre-specified themes HOT 2
- "Error : node stack overflow" when downloading data HOT 4
- [Feature] Change Overpass API server HOT 2
- [Bug] Error when asking local Overpass API server HOT 2
- Disable certain type of buildings (or other OSM features) HOT 4
- [Feature] I would like to be able to select cities by lat/long, or by city & country HOT 2
- [Question] HOT 3
- HTTP 504 - Gateway Timeout HOT 3
- Error In Installation HOT 3
- Error in installation HOT 5
- Choose cities or towns or areas by coordinates HOT 3
- Installation error HOT 1
- git history is huge HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rcityviews.