Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v.to.rast: ignore null entries of attribute values for use=attr #173

Merged
merged 2 commits into from
Nov 6, 2019

Conversation

metzm
Copy link
Contributor

@metzm metzm commented Oct 31, 2019

ignore null entries of attribute values for use=attr

if an attribute value is null, the corresponding vector features will not be rasterized

ignore null entries of attribute values for use=attr
@metzm metzm requested a review from veroandreo October 31, 2019 20:16
@veroandreo
Copy link
Contributor

I applied the patch and it works as expected according to the change proposed:

g.copy vector=zipcodes,my_zipcodes
g.region vector=my_zipcodes res=100
v.db.update map=my_zipcodes column=ZIPNUM value=NULL where="ZIPNUM == 27596"
v.to.rast input=my_zipcodes output=my_zipcodes_rast use=attr attribute_column=ZIPNUM

image

I agree with this change, but please see the comment by Micha in grass-user for a different opinion: http://osgeo-org.1560.x6.nabble.com/Null-values-in-attribute-table-get-converted-to-0-zero-during-v-to-rast-td5419967.html

@HuidaeCho
Copy link
Member

HuidaeCho commented Nov 1, 2019

Personally, I agree with Micha. Polygons with null attributes deserve to be converted to raster cells in some cases. How would we know locations that exist, but do not have any data vs. non-existent locations? For example, county census data may not be complete and some counties may have no population data yet. When you convert this population data to raster with this change, you would need a secondary layer to identify those counties with no data vs. unincorporated areas (or just outside the data boundary)? I believe we should have an option to choose which one we want. Maybe, null_value= option with default NULL so you have to specify a target null value knowingly (e.g., -9999).

print message if missing attribute values are replaced with 0 (zero)
@metzm
Copy link
Contributor Author

metzm commented Nov 1, 2019

I agree with Micha. Besides, all possibilities can already be done without any changes.
If you don't want features with missing attribute values to be rasterized, use v.to.rast where="column is not null".
If you want another value than 0 (zero) as replacement, use v.db.update where="column is null" + v.to.rast use=attr.
This PR is now only printing a message if missing attribute values are replaced with 0.

@neteler neteler merged commit 1762dd0 into OSGeo:master Nov 6, 2019
neteler pushed a commit that referenced this pull request Nov 6, 2019
…h 0 (#173)

print message if missing attribute values are replaced with 0 (zero)
@neteler
Copy link
Member

neteler commented Nov 6, 2019

Backported to relbranch78 in 9460807

@metzm metzm deleted the v_to_rast branch November 6, 2019 18:52
petrasovaa pushed a commit to petrasovaa/grass that referenced this pull request Dec 3, 2019
…h 0 (OSGeo#173)

print message if missing attribute values are replaced with 0 (zero)
landam pushed a commit to landam/grass that referenced this pull request Jan 28, 2020
…h 0 (OSGeo#173)

print message if missing attribute values are replaced with 0 (zero)
@neteler neteler added this to the 7.8.1 milestone Dec 9, 2021
@neteler neteler changed the title v.to.rast v.to.rast: ignore null entries of attribute values for use=attr Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants