我正在尝试为加拿大各省创建一个空间数据的MySQL数据库。
我从https://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/files-fichiers/2016/lpr_000a16a_e.zip下载了.SHP文件,并尝试使用ogr2ogr
工具将文件转换为MySQL的空间数据。不幸的是,我可以在Mac上安装的ogr2ogr
只能进行PostgreSQL转储,但看起来数据是WKB格式的。
因此,我使用以下命令创建了转储:
ogr2ogr -nlt GEOMETRYCOLLECTION -f PGDUMP canada.sql lpr_000a16a_e/lpr_000a16a_e.shp
然后我手动编辑了SQL文件,因此现在看起来像这样:
CREATE TABLE `region_data` (
`country_code` CHAR(2) NOT NULL,
`state_code` VARCHAR(10) DEFAULT NULL,
`geom` GEOMETRYCOLLECTION NOT NULL,
);
INSERT INTO `db_update`.`geospatial_region_data` (`country_code`, `state_code`, `geom`) VALUES ('CA', 'PE', ST_GeomCollFromWKB(X'0107000020E610000001000000010300000001000000AB010000C9C00D64CB284FC01E149DF61E154740AA51B1FC5D2C4FC0A5359B753310474043FFB45F902D4FC0A02924068D0E474047D072CFE5304FC0EE9E68FFF20947402239065605334FC0FDD2BA8DF2064740817A438C01344FC03E468CB08D054740860F99EDC7354FC0CF1402510A034740AE5813E465364FC0C782B2832A024740AE892E273C384FC055AECA0F0200474016606B4C3C384FC0745FDEE301004740121891703C384FC01D4B78B901004740D58538836D384FC09416890CC8FF464091E7F54478384FC04437E967BBFF4640903E0C5C163B4FC01B4D76AF6CFE46400C195075B63E4FC085CD829B9CFC4640D1C7130000404FC0E5D256B1F7FB46402302F9FFFF3F4FC00D384670A0FA4640FD26D4FFFF3F4FC039B2E16ABFF8464054271D0000404FC05D5B9F273EEE4640E79F6E3026454FC0C496CDBA2DEE46402EF5439E5F464FC0CC28570A27EE4640BE3925F167464FC037D6ADDC26EE4640165C064470464FC002FE02AF26EE4640F8220983A9504FC04E67F783EDED4640338B348FB1504FC0A5CB2456EDED4640C80AD7BCB1504FC0AAF065CEEDED4640BB93FDB02C524FC0BF555F4CE9ED4640CA697F0435524FC0A014EA32E9ED4640E96141A60E594FC05E0B8FB5D3ED46406EABB67273594FC0D7818944D4ED4640D0D56FC67B594FC0BCE94950D4ED46405F9F1C47F95A4FC021123371D6ED4640F4CBA053945F4FC092542386DCED46409D4360A79C5F4FC0D7C2C490DCED464066B31FFBA45F4FC0748A649BDCED46409ED12B6C90604FC053781EC6DDED46408F58EE9038624FC028779E150FEE4640FC39E7C740624FC04EA9E60910EE464007D0E0FE48624FC0FC612DFE10EE46408C6FBFC17D634FC06DC0E8D834EE4640553CD4F885634FC05B93F6CC35EE464019AEE92F8E634FC0AD0203C136EE4640899B653917654FC09D1F1B5864EE4640AF869D701F654FC0BE71DF4B65EE46407D45D6A727654FC01455A23F66EE4640827C322262674FC098AB1152A8EE464062CB9C596A674FC0B8AB6C45A9EE4640E6AE079172674FC07627C638AAEE46405BF19242C3684FC0761F6429D1EE46404B25AB01EF694FC02E65905904EF46400097F018F7694FC0269535BB05EF464051FA3630FF694FC09F38D91C07EF4640736D80F43A6C4FC026C547A868EF464046000F0C436C4FC0379785096AEF464004859E234B6C4FC04913C26A6BEF4640D57B5058296F4FC09C73047EE8EF4640FED45E50A76F4FC0B6A17F2208F04640BB832827AF6F4FC09AAE881A0AF04640F2C4F3FDB66F4FC0895F90120CF04640A3CB89D8D7724FC0AA964615D5F04640DF45E4AFDF724FC0C3A1C60CD7F0464098234087E7724FC0E75B4504D9F046405C3FE5C2BC744FC01B7F58AA4EF14640A7ADE21821764FC0C5B7D5ACD8F14640CA73926228764FC061065D7FDBF146401D1444AC2F764FC05D3CE351DEF14640AB683432A4794FC092EBCC9A34F34640A1AFC87CAB794FC0BDDDCC6C37F346406AC15EC7B2794FC0E6CCCB3E3AF346408AD20894307C4FC0BC7343CC30F4464002541A9F777C4FC0F12F128160F4464053AA12A17D7C4FC06B76E18964F44640EA6453A3837C4FC06805C89268F44640F6190D0000804FC02D7FDC68BFF64640543BABC7A1834FC051F89A992EF9464027217C3114854FC0DA584C3965FA4640ABD1D98719854FC0CC07E6B269FA4640A1B939DE1E854FC058647F2C6EFA46408C2997818A874FC09459ED6A75FC4640A7E37C21198B4FC0C66F1CDED9FE4640836E8601BC8B4FC06C5D3E8346FF4640489A710AC28B4FC000BFA6894AFF46401DF75E13C88B4FC07D780E904EFF46401A6B2E19D68C4FC0810F8B9F020047409346CF34D68C4FC008ACE4B10200474071BF73EE6B8D4FC0474A668266004740199B5CDDF5904FC0B9E7429D6D014740AE9F714CAF924FC04AEA52F5EF014740FAE43EFBB6924FC08745DA39F2014740A7D4E59D40A34FC0DCF8A8B0B3064740FAE08C5948A34FC023FB34E8B50647404E3CAD1450A34FC042208420B8064740EC5085A14CAA4FC02F0523EAB8084740F11A765E54AA4FC0819B3221BB08474090B10AA356AA4FC0E3935CC7BB084740456ACC575CAA4FC0CFE73C82BC084740D8668CE18EAC4FC0F0800D6404094740626DE21997AC4FC0A2CFC770050947407C6E15509FAC4FC099F8008606094740C6F87F4E87B54FC0C6561751320A474055E195BBE2BD4FC0932FC242520B474013E88CF3EABD4FC0FBA32E5D530B4740C1CF842BF3BD4FC0C68A9977540B47407B4913358DBE4FC05F72A422690B474042DA10D6FFBF4FC00B6E5F7D960B47407732180000C04FC03BBF6182960B47402F37097523C44FC0931CB1E3170C4740BA2019B42BC44FC0122E31E5180C474028CA29F333C44FC0FFC4AFE6190C474041BDF3F824CA4FC0A313A7F2D20C47407435352AA9CA4FC01AD99FF0BC0C4740C215EC4EB1CA4FC05B366C95BB0C4740DA358073B9CA4FC09C6B683ABA0C474013B079031BCD4FC0D19C9FA8540C4740A259B40BA7CE4FC0C1DC5FA8EC0B47400408812EA7CE4FC0B535239FEC0B4740344FBDDEAECE4FC0E775299AEA0B4740632BCE81B3CE4FC00900B052EF0B47402EF37DB9B3CE4FC0E77F938BEF0B4740880D0C26F7D24FC0F964A6D945104740610E1CE1FBD24FC0B4C493A84A104740FD2C2E9C00D34FC07FC480774F104740D4D0660F92D44FC0C92B765EE7114740129829CB96D44FC0655F4A2DEC114740E07CA7869BD44FC052DC06FCF0114740AA0CE848A8D94FC0B7A7FBB9101747403661E106ADD94FC0CC19808815174740DA0EAF3A3ADA4FC017B027A5A417474058CCBA2748DB4FC0AF284721B61847409C469DDAB8DE4FC0B967ED9E311C47408D01B99CBCDE4FC0A883146C351C4740FCEA677EBFDE4FC0A8956F56381C4740E55BCB36C4DE4FC01B24A71C3D1C4740F01FE3C385DF4FC0EC8F13DD001D4740788AA122E3DF4FC08A7189C6611D4740A02155156AE24FC096BC48BE0020474051B16A1E6AE24FC0101965C7002047404DCEFE108BE24FC03FFA91EE22204740A8B4998593E54FC0A6847B646122474014C5FEB1B5E64FC0381705303A2347408EB0F78FEBE64FC0F8D03D6C62234740B0C8FE47A5E84FC00E85F51FA624474085420C0F66E94FC05BA38784342547400262A8E66BE94FC0CB0305D538254740F3BF2FF6AFEA4FC036A3DD7CFB254740CD2EDF154DEB4FC0DDF058A0512647402835646633EC4FC0C7785B88D0264740D9F13D4FA2EC4FC077A9B3A10D27474084FCE72D7EEE4FC068B67EB7D92747407A759A8F9FEF4FC023E1473E52284740A61AA06B36F14FC0871B47ECDD284740FFE58FF397F24FC0DB9E30245829474034FCC41BE4F34FC0F833C030C1294740AD88B19631F44FC0BBDC7A82D6294740A07E992123F74FC05B842B00B72A47409E237D9E8CF84FC0310BDB29012B474040F942138BF84FC08AAC8A98FC2A47400102E5FFFFFF4FC0AE74BBBF922F4740064D5C06000050C005A86CC7922F4740947B47283E0050C0736B621CDF2F474006DF6A7A5A0350C01EE9A5C9D03047405B9449C6080450C005C30790053147404E9877CB220450C0306705700D3147403548602A430550C0F88B88A5643147403EB702F9620550C05DAD5F296E31474074B61F43040750C091150EDBEA3147405CBA986DBC0A50C0C7FA5F7106334740A0B5DE13990A50C0D3C02CBAC7334740C19B08A0740A50C02CEDE0538434474075BEA77FE50950C08C39F8656837474047D2B928A70950C0683B14E3A7384740B241EB50620950C02A47DA8C083A4740C5B459A61A0950C084A96281773B4740DD1CE878DD0850C0607ECF69B63C4740F5443AE5670850C00DB914F21A3F4740CF61D95E3B0850C0ED41C9C60240474020CFC2C9290850C024E1EB4D5E4047401DCAF55CF70750C005B616F8644147404CC8A6FEBC0750C03ED2A4E694424740BBDBE396670750C04CE282665144474075C02B5E180750C04E11397BED454740C062BC9EDC0650C0D0E175212247474048A3B3359E0650C0F6108E7E6F484740A4B3A1D9C90650C098744128ED484740A1C8CE2A3D0750C056FE77E1044A4740AA37CB783C0750C0C95AC2E4054A4740414DEED14B0950C02DA239F1CE4A47400535A451870B50C05E121A26464B47402A3159F2050C50C008A2B2FD604B474067076B899A0D50C0341C3F9BB64B474037999BA8EA0E50C07118D730D44B47409984AD2C621150C0275EDD63314C4740625766923B1350C089B0B7E6764C4740C8C07F0EC51350C02EFE5B18824C4740BA36811B481450C0CAE2CBBD8C4C4740AD5AC41BFA1450C018C82E2A9B4C474075C5C3DCF01650C074BA13ADC34C4740DF423ADD461750C0BFFA8E92CA4C474032B5D3C8FE1750C0777CB249D94C4740DD0B2931651B50C043F406511E4D47403BE2810FA41B50C027F1A713334F47404B225786EE1B50C0927FB5A0A95147404236A0E1131C50C0549B90C3E552474031002CED561C50C084A907D31C554740EDA772586E1C50C0152E8886F35547400A923D878B1C50C0454AE6FAFE56474020B55778D51A50C0A6D5BFD1AE5B4740534F5A71DD1950C0531A1F3F555E4740236F4CA6431950C077FB12640260474065BC488A431950C05FE585B2026047400002DDC4DE1850C085060ABF1B614740C60785C0841850C04D3422A3BD61474079C2FACCF71550C0C3E6082F36654740ED18DF8B3A1450C044912248A9674740E0EA30C8391450C03DB1F571A6674740C688F59B0A1450C09EE73937DA674740A2DD8081BA1350C0455BD83A47684740695C4146771250C06CC4588F7A6B4740CA06F0C4C01150C09B25817D486D47407EB0D87A971150C0193CE6CEAE6D4740B18864FACC1050C0902B9CEBA86F4740B5F885DD1C1050C0834E255867714740F7CB7675680F50C0EA4747593073474099D508CB510F50C0241B6AC3667347403A81BEFEC20E50C0BA344AE6DD7447409CE805F4790D50C0F58B6B4CAF7647401B4893ABB70C50C036AEDAE5C177474058A90CEE810A50C093BFF9AEE07A47406F7C6886450A50C01B49E3E5357B47409B4079C79A0750C05245A47E197E4740092818E8720650C096B9EF98597F4740A7A493D3520650C09969374A7C7F47402E1BD88B520650C0887496977C7F4740C1358CFFD60550C08523B42C02804740D75825A6D60550C00957778D0280474048E71B4EE00450C0165861C60C81474049B39DD0780450C0D011D1907C8147403BA8F350240450C063987EEE02824740328A5E5B1A0450C0B2C30BC412824740E9AE982B9F0350C05B7FBE96D6824740E3E01C352E0250C009E20DB220854740434AEF012D0150C09CB420E6B88647408CF6B4EB770050C0B351AD1FD8874740C3782C95210050C07F0E760361884740D4480D00000050C00D36B72F62884740D48B07E8FFFF4FC0B4490A3062884740AC0C2D7570FD4FC0D400298E6D884740FBDEAA6283FC4FC0EDE8F9A171884740CF93EDE276FC4FC0BB50199123844740A92B875773FC4FC00735CBBBEA82474030C91DE66AFC4FC08096541801804740AB24ACE56AFC4FC02863CE00018047403AECAE9763FC4FC08D3D234A7B7D4740872FD0C760FC4FC09247A998827C47404B9EC98C5CFC4FC0289758520C7B474070DF5A3D5BFC4FC0A27C8859987A4740F5E9DA2558FC4FC0A75B669A867947408DA26C0B58FC4FC00778B67C7D79474042D10C426CFC4FC0DA6EABB083744740C7E6FD3E7DFC4FC00A12A0B0FD734740922A629582FC4FC0285DE495D3734740D0E45C7C8EFC4FC060B854BB237247408D30172C89FC4FC0919737ED5470474017A243CD98FC4FC061AD8A82F66E47405CFD0DC9A3FC4FC0C8416CE1B66A474099294C3BA7FC4FC0DE5DA66561694740F60B2BB4B0FC4FC0BEA03A25116847406CB5E95FCEFC4FC01D40D5DDC6664740F13309FAD0FC4FC01C4D3EFFB2664740DD2E09AD25FD4FC094457BD9A761474013B74D2A30FD4FC04E07EEE200604740EC0B6FEE33FD4FC09CECF4F2685F47409D44AC5E68F94FC0EE653EBEAF5C4740FBBBE07729F44FC09C092552C6584740104D7C91F1EF4FC0AF252BAB0856474021FE3966EAEE4FC00D88F0D35B5547404F6EA56139EC4FC059501F04975347401CF1C65509E94FC0675ED6EBDD514740D7A5C47017E64FC06A35851B69504740289E23E41EE14FC07DF63087044E4740F3CD4464DBDB4FC0DFEBC169794B4740B816D8EA98D84FC043C8C39EE749474056D154E3F7D24FC005ADD032EA4947406C23E78A45D14FC0C2602FD7EA4947406A967BA4D9D04FC0E6BD9BFDEA4947402EC23DCB93CC4FC08A5E8A37EC4947409DBB39133FCA4FC0BA17A4746A4947403C106F8551C84FC03EC5CB05FF4847406B5F4E17B0C74FC06B3FB169CE48474029C03FFF54C54FC0EA5AE7B418484740F11DE1A405C14FC0E50CC8DBCB4647400714210000C04FC0DA70FE5E2B46474059964321CABD4FC0142CAF16D0444740FC06C38572BD4FC0BE5CCF4C9A444740AF343A204CBD4FC08EC959759044474029434936B8B54FC00496FC6B9E42474084629BFD36B54FC0DCAD16317D424740927DDBD3C9B44FC0D844748F6F424740D6B63A79B1B44FC0A872A9846C424740F2AF490466AE4FC0937AA8CAA2414740C2741FF065AA4FC0281F201F22414740369F7F1B55A64FC00AC8C3C30140474095CF3D7A54A64FC0354B1897014047409305619316A34FC0561455561B3F474068EB1FC4BFA04FC037FFF423763E47404D4846B01DA04FC03F5FA266493E4740C13685EC8D9F4FC04A5CFBB4213E474092070E12379E4FC07110EE28C23D4740556A73DF179D4FC0828F7315723D47404607365972984FC0839AE03AFE3B4740B7EEA6B313914FC014B07D1A3C3947400A7BE9830B914FC0FD217402393947409AB774DA9B904FC08B9BBEC70A3947402FEDD642E68F4FC09306F593C138474055CD9B934E8F4FC0F6558849843847409D4DC1E9B18E4FC091446B5E44384740927D54E1258E4FC0AC1528E90B38474032733614978D4FC007318091D1374740F5A56154038D4FC0CE00E77F96374740EF8CD6B2708C4FC0913678CB5B374740D009185DDE8B4FC017A1BAA621374740818DF417A18B4FC07961F01C09374740113C5FC14B8B4FC0E8A8C8EEE63647409CC11CE8B88A4FC006E54F8AAD364740D8B7A456268A4FC0FF3948C2733647407C415DB3C5894FC0985BF8533E36474070F8BE0000894FC0CFAFE98E51364740371B5CFD4F884FC0E67AA34C643647406AEFE2CA48874FC0F428834D80364740CE3C583988864FC03A2DAD7894364740D5BEBC385C864FC0FAA8D54599364740FF38586C41864FC08FF581329C364740BC85013D19864FC024D8DA94A0364740A09C51ED58854FC09D9D608EB53647404A878CB82D834FC0359DC099F636474092A7B5B9F3814FC0602FF70319374740143AAB943F804FC0716777A44737474022EEFBFFFF7F4FC0687D59E850374740DF776ABDC67E4FC0B57DFA887E374740BF1D4B82777D4FC01C77B1B9AD37474049D58DCDB87B4FC0E9321805EB3747400BECAA3DB27A4FC0E64AC3F312384740956718A70C794FC03F6CAD494B3847402747CFED48784FC0BD6AD0066A384740E331111B03784FC0B5739C7E7038474034BA96B6E8774FC02E3E1A3074384740EE21FD6BC56E4FC0A042C78FF93747409C333D64BE6E4FC0BDBE7839F9374740A4996D58C1664FC0378F3E0A38384740D05D3140A3664FC0974994EF3D384740D4A1FC9732634FC0283D7D5AE73847405296E7D9BD5D4FC0E6FCB073F3394740D1EAEB97DD524FC04BC4D4F1EA3B4740CCA47EA2FA514FC088659C88053C4740C9C37DAA42514FC0119A9FCA103C47408005B2FFCE4E4FC028BB55CB443C4740B55F1331674A4FC02C672B95943C4740F2D4628478484FC0E9897B30BF3C47403421B5FA7D464FC039111759E13C474074F21BA405444FC04EFBA61C0A3D47400CA161F4A9414FC05A8F7DC9343D4740A65F280873404FC0885590F6463D4740D8549E0900404FC077C2ECAF4E3D47409E1B170000404FC0E672B3B04E3D474072F6B348B73E4FC045E326BF643D4740631C1F7B953D4FC0D69B0BE8783D47402E19BAEF563C4FC05598F21F763D4740D5925C4DD2394FC014D0B577703D47402E1F0283CF394FC0F3AD483E703D47403AEECA4B51384FC0FC1E7A79513D4740FD7D043F2A364FC0DCF6A04E2D3D4740DA830A29E2344FC0CDA15E47163D47403C6AE0D816344FC0D8E896FD073D47404C1FB20B5E324FC0AC795890E23C474082E95E923A324FC049B9B55EE43C4740E7C65CAD78284FC0156353454C3D47402357B84EFF244FC04CAC39B9913D4740996CB5BFFB1F4FC0FA15757CF53D4740F5B5FB33D5154FC007F07ABEBD3E4740CB4ECF0EBB154FC06CF47CBCBC3E4740AE76EFDD21144FC0F9D573F0AC3E4740DBF360B930114FC04CDF14B88F3E474038FE58A4280E4FC000C23E69713E474020D0C066660B4FC0F51EFCA7553E474035037DF9240A4FC00F2323F8483E4740A31795B378084FC005E9DE02383E474025533A58AC054FC08AC87F821B3E474037C4D613B9034FC0E9E0618B073E4740048C0C0000004FC0028B16F95E3D47408830B5C9FFFF4EC001419CEF5E3D47404A6683E795FF4EC024BBFF2F4C3D4740BE1476B990FF4EC0D7610D454B3D4740025765E7B4FD4EC09772A3F6C93C4740DCC50054A6FB4EC09304A0C03A3C4740B6E7EF418EFA4EC0BEBBD675963B4740DF43BA353DFA4EC011CE7B5D7F3A474059AACD36FBFB4EC0CF8379898838474072EC29F47CFD4EC0DF45872F08374740AAC4C2E609FF4EC0871BFF6B7C354740979547BEFFFF4EC0F6448711E434474091C1230000004FC0FB4BC7E8E3344740FB39551100004FC089B611DEE33447400093615255034FC0E24EE8B4D232474013A740C09C044FC04F36C77C0732474065C8372632054FC0448001BCAA3147402B3331CAB9064FC0D298FC7FB73047400EB95D3B45084FC06FF91FC7C12F47406B365EFEEB094FC00B60FDEFBA2E47408EAA4E705D0B4FC067DF3820D52D474033EB84A5620D4FC09D715136932C4740F786A63C640D4FC08374E438922C474099FBF027790E4FC08ECA53C6E52B47405FAEA3A2B70E4FC07681ADDBBE2B4740845E7F44940F4FC0D0AD07AE392B4740617871B29A124FC0E4895AEA65294740FE3E241D82164FC030A8138E092747409221310527184FC0D2479ACA0A2647406BF472A6B31B4FC0A18C6F57E4234740C66DAD146A1C4FC06E8F67D2472347406E983A42B71F4FC0EF47948B39214740ED1C2DC012214FC08AF7A09A332047407C6DFD1C4A214FC078E20624E71F47407CCB6190A8234FC03DB0ECBD091C4740CC3534AD70264FC0F6EF065F4618474010CD192073264FC0D493520E43184740D103EA9D7B274FC01F22042C03174740C9C00D64CB284FC01E149DF61E154740'));
但是,当我运行查询时,我得到Invalid GIS data provided to function st_geometryfromwkb.
。知道发生了什么吗?我尝试在https://rodic.fr/blog/online-conversion-between-geometric-formats/上“验证” WKB数据,看来还可以。
答案 0 :(得分:1)
我做了一些调查:
1)在BigQuery中运行此命令,它会报告更好的错误消息(使用完整的WKB字符串,此处缩短):
select ST_GeogFromWKB(FROM_HEX('0107000020E610...'))
获取ST_GeogFromWKB failed: Unknown object type 536870919; during WKB parsing
2)将536870919转换为十六进制,得到0x20000007
3)在Google上搜索“ WKB 0x20000007”,找到了有关ZM几何的EWKB建议:
https://lists.osgeo.org/pipermail/postgis-devel/2004-December/000710.html
显然,MySQL和BigQuery都不支持此扩展。