Comments (7)
The numbers are rounded when print, but they still have the same precision. See:
library(sf)
multipoint_matrix = rbind(c(1.0000005, 2), c(1, 3), c(3, 4), c(3, 2))
mp = st_multipoint(multipoint_matrix)
mpc = st_coordinates(mp)
mpc
#> X Y L1
#> [1,] 1.000001 2 1
#> [2,] 1.000000 3 1
#> [3,] 3.000000 4 1
#> [4,] 3.000000 2 1
mpc[1,1]
#> X
#> 1.000001
formatC(mpc[1, 1], digits = 10)
#> X
#> " 1.0000005"
from geocompr.
bit easier with
op <- options(digits = 16)
## st_coordinates(mp) etc
options(op)
from geocompr.
When you read in the dataset that you exported into QGIS, do you still have the same number of decimals? Because we're reading in data using gdal and i don't expect it to drop an precision.
from geocompr.
Hi @sy5938 you could try st_set_precision()
or after converting to numeric values with the round()
function in base R. Does that help? If you have a reproducible example to show what you have tried and what you're trying to achieve that could help. Interesting we don't seem to mention st_precision()
or related functions in the book: https://github.com/search?q=repo%3Ageocompx%2Fgeocompr+precision&type=code
from geocompr.
Hi Prof. @Robinlovelace .It doesn't look good.
Sorry I can't provide the original shpfile data, so I randomly sample 4 points (Uploaded as an attachment sample1.zip).
My code:
library(sf)
test_point <- read_sf("sample1.gpkg")
st_set_precision(test_point,0.001)
st_coordinates(test_point)
Using the sample data, the st_set_precision()
also didn't work well. Did I miss something? Perhaps read_sf
directly drop the decimal? If read_sf
can set an argument, that will be good.
from geocompr.
Thanks a bunch! Very clear now.
from geocompr.
@mdsumner Wow! Thanks for your wisdom. I shouldn't forget the most basic R setting. My bad....
Guys in this issue, I appreciate all your time! Thanks a lot!🤘
from geocompr.
Related Issues (20)
- Legends overlap objects in Figure 9.6 HOT 3
- Subsetting multilayer rasters with double brackets [[ ]] HOT 1
- Restructure data I/O chapter? HOT 10
- Additional information about Table 5.1 regarding geometry conversions might be needed HOT 5
- Add formula for resolution to Chapter 5 HOT 2
- GitHub API maxxed out HOT 7
- Update workflows to use r-universe
- Using write_sf() to add a new layer (8.4.1) HOT 7
- style argument for some tmap functions is deprecated HOT 4
- About contents HOT 3
- Ch. 5 Exercise #4 faulty solutions HOT 1
- Error in chapter five, code chunk 6 HOT 8
- Code fails in section 12.5.1 HOT 5
- Error in Section 8.9 HOT 1
- Proof-reading - RL
- Review Edition 2 RL II
- Move checked-in images in figures/ into images/'
- Reference error in text of section 2.2 HOT 1
- Reword content that relies on hyperlink 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 geocompr.