Mapping Toolbox - areaint - Wrong area calculated

2 Ansichten (letzte 30 Tage)
Nathan Kamphuis
Nathan Kamphuis am 15 Apr. 2020
I'm working to calculate the area of polygons defined in the US 2010 Census Block data set. I'm calcuating the area of each block and summing to find the area of a US County. I'm using Alcona, Michigan as a test case and getting the wrong area. Since the blocks from Census Bureau is completely cover the county the method should work. Since the code uses all built in functions, I'm not sure how to begin to troubleshoot the problem. The code is not perfectly written, yet should work just fine. The code determines an area of ~303 sqmi when that is clearly not correct. Any ideas on what is wrong or how to trouble shoot the problem. All you need is matlab, the mapping toolbox and an internet connection to download the files noted. Just go all the way to the bottom of the page and in the Block drop down select Michigan.
clear all, clc, format long, format compact,
% This code loads a US census block file (given by state and DC)
% the file contains the population within the block and the GIS data
% defining the block for each block within the state or DC that is loaded
% https://www.census.gov/geographies/mapping-files/2010/geo/tiger-data.html
% Written by Nathan Kamphuis 4-15-20
%% loading Census Block (takes a bit)
Block = struct2table(shaperead('tabblock2010_26_pophu.shp'));
%% Formatting Block
[ p, q ] = size(Block);
Block{:,13:14} = NaN(p,2);
Block.Properties.VariableNames{13} = 'Area';
Block.Properties.VariableNames{14} = 'Density';
list = unique(Block{:,6});
%% Calculating area of a block
Earth_miles = wgs84Ellipsoid('mile');
Block_sub = Block(strcmp('001',Block{:,6}),:);
[ p, q ] = size(Block_sub);
for i=1:p
block_area = areaint(Block_sub{i,3}{1},Block_sub{i,4}{1},...
Earth_miles);
Block_sub{i,13} =sum(block_area); % sqmi
Block_sub{i,14} = Block_sub{i,12}/Block_sub{i,13}; % ppl/sqmi
end
%% Testing numbers
block_sub_total_pop = sum(Block_sub{:,12});
block_sub_total_area = sum(Block_sub{:,13}); % Area should be Area
% • Total 1,791 sq mi (4,640 km2)
% • Land 675 sq mi (1,750 km2)
% • Water 1,116 sq mi (2,890 km2)
% https://en.wikipedia.org/wiki/Alcona_County,_Michigan
% This is also consistant with county level data from US Census Bureau

Antworten (0)

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by